<?php
require_once("database.php");
class xl_ho_tro_truc_tuyen extends database
{
	function danh_sach($vi_tri, $so_luong)
	{
		$vi_tri = intval($vi_tri);
		$so_luong = intval($so_luong);
		$sql = "select * from ho_tro_truc_tuyen limit $vi_tri, $so_luong";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function so_luong()
	{
		$sql = "select count(*) from ho_tro_truc_tuyen";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	function xem($ma)
	{
		$ma = intval($ma);

		$sql = "select * from ho_tro_truc_tuyen where ma = '$ma'";
		$this->setQuery($sql);
		return $this->loadRow();
	}
	function xoa($ma)
	{
		$ma = intval($ma);

		$sql = "delete from ho_tro_truc_tuyen where ma = '$ma'";
		$this->setQuery($sql);
		return $this->query();
	}
	function them($ho_ten, $loai_ho_tro, $nick_chat, $trang_thai, $thu_tu_hien_thi)
	{
		$ho_ten = addslashes($ho_ten);
		$nick_chat = addslashes($nick_chat);
		$thu_tu_hien_thi = intval($thu_tu_hien_thi);

		$sql = "INSERT INTO ho_tro_truc_tuyen(ho_ten,loai_ho_tro,nick_chat,trang_thai,thu_tu_hien_thi) VALUES ('$ho_ten','$loai_ho_tro','$nick_chat','$trang_thai','$thu_tu_hien_thi')";
		$this->setQuery($sql);
		return $this->query();
	}
	function cap_nhat($ma, $ho_ten, $loai_ho_tro, $nick_chat, $trang_thai, $thu_tu_hien_thi)
	{
		$ma = intval($ma);
		$ho_ten = addslashes($ho_ten);
		$nick_chat = addslashes($nick_chat);
		$thu_tu_hien_thi = intval($thu_tu_hien_thi);

		$sql ="UPDATE ho_tro_truc_tuyen SET ho_ten= '$ho_ten', loai_ho_tro= '$loai_ho_tro', nick_chat= '$nick_chat', trang_thai= '$trang_thai', thu_tu_hien_thi= '$thu_tu_hien_thi' WHERE ma = '$ma'";
		$this->setQuery($sql);
		return $this->query();
	}
	function tim_kiem ($tu_khoa)
	{
		$sql = "select * from ho_tro_truc_tuyen where	$ho_ten like %tu_khoa% or 	$nick_chat like %tu_khoa%"; 
		$this->setQuery($sql);
		return $this->loadAllRow();	
	}
 }
?>